import ccclass = cc._decorator.ccclass;
import PopupWindow from "../../framework/PopupWindow";
import property = cc._decorator.property;
import { WindowName } from "../../framework/reflect/WindowName";
import Context from "../../framework/Context";
import GameWindow from "../windows/GameWindow";

@ccclass
@WindowName("ShowWeaponInfoPopup")
export default class ShowWeaponInfoPopup extends PopupWindow {

    private data = null;
    private lv = 0;

    public static showUI(data): Promise<ShowWeaponInfoPopup> {
        return Context.get().popup(ShowWeaponInfoPopup, true).then(info => {
            cc.log("showUI",data)
            info.initData(data);
            return Promise.resolve(info);

        })
    }

    @property(cc.Label)
    private text: cc.Label = null;
    @property(cc.Node)
    private returnBtn: cc.Node = null;
    @property(cc.Node)
    private startBtn: cc.Node = null;
    @property(cc.Label)
    private waeponName: cc.Label = null;
    @property(cc.Label)
    private waeponExplain: cc.Label = null;
    @property(cc.Label)
    private waeponInfo: cc.Label = null;

    public onStart() {
        this.bgClickable = true
        this.setCancelableOutSide(false);
        this.setClickListener(this.returnBtn, this.onReturnBtn);
        this.setClickListener(this.startBtn, this.onStartGame);
    }
    private onReturnBtn() {
        this.finish();
    }
    public initData(data) {
        this.data = data;
        this.waeponName.string = data[0]['name'];
        this.waeponExplain.string = "需要一把+"+data[1]+data[0]['name'];
        this.waeponInfo.string = data[0]["desc"];
        /* var mask = new cc.Node();
        var mask_node = mask.addComponent(cc.Label);
        mask.parent = this.node; // mask_node.parent = mask;
        mask.x = str.x;
        mask.y = str.y;
       mask_node.string = "ssssssssss"
        cc.log(mask)
        mask.width = 50;
        mask.height = 50; */
    }
    private onStartGame() {
        this.finish();
        GameWindow.sendData(this.data);
        
    }
}